package com.example.tse.rbhttpservice.service.activities;


import android.content.Context;

import com.example.tse.rbhttpservice.service.HttpService;
import com.example.tse.rbhttpservice.service.RemoteServiceListenerT;
import com.example.tse.rbhttpservice.service.ResponseServiceListenerT;
import com.example.tse.rbhttpservice.service.RudderResponse;
import com.example.tse.rbhttpservice.service.activities.model.ActivitiesSeckillNoticeRequest;
import com.example.tse.rbhttpservice.service.activities.model.ActivitiesSeckillNoticeResponse;
import com.google.gson.Gson;

import org.kymjs.kjframe.http.HttpParams;





/**
 *
 * @author wliu
 *    edi  tse
 */
public class ActivitiesSeckillServiceImpl implements ActivitiesSeckillService {
	private Context context;
	private static Gson gson = new Gson();


	public ActivitiesSeckillServiceImpl(Context context) {
		this.context = context;
	}
	/**
	 * 未开始的秒杀商品有该功能，点击多次可切换状态
	 * @param request
	 * @param listener
	 * @return ActivitiesSeckillNoticeResponse
	 */

	    public void notice(ActivitiesSeckillNoticeRequest request, final RemoteServiceListenerT< ActivitiesSeckillNoticeResponse> listener) {

        final HttpParams params = new HttpParams();


            params.put("productId",request.getProductId());
            params.put("secondId",request.getSecondId());
            params.put("deviceId",request.getDeviceId());
            params.put("isSet",request.getIsSet());

        final String url = "activities/seckill/notice";


            new HttpService().post(context, url, params, ActivitiesSeckillNoticeResponse.class, new ResponseServiceListenerT<RudderResponse>() {

            @Override
            public void onPreStart() {
                super.onPreStart();
                listener.PreStart();
            }

            public void ok(RudderResponse rudderResponse) {
                super.ok(rudderResponse);
                listener.ok((ActivitiesSeckillNoticeResponse) rudderResponse);
            }

            @Override
            public void okData(RudderResponse rudderResponse) {
                super.okData(rudderResponse);
                listener.okData(rudderResponse == null ? new ActivitiesSeckillNoticeResponse() : (ActivitiesSeckillNoticeResponse) rudderResponse);
            }

            @Override
            public void okData(RudderResponse rudderResponse, int fromWhere) {
                super.okData(rudderResponse, fromWhere);
                listener.okData(rudderResponse == null ? new ActivitiesSeckillNoticeResponse() : (ActivitiesSeckillNoticeResponse) rudderResponse, fromWhere);
            }

            @Override
            public void onFailure(int errorNo, String strMsg) {
                super.onFailure(errorNo, strMsg);
                listener.failue(errorNo, strMsg);
            }

            @Override
            public void onFinish() {
                super.onFinish();
                listener.Finish();
            }

            @Override
            public void onMessage(String message) {
                super.onMessage(message);
                listener.onMessage(message);
            }
        });
    }




}